home *** CD-ROM | disk | FTP | other *** search
- ;RDIR.ASM Rename Directory
- ;
- ;12.18.84 Zider Brothers, San Francisco (LSZ)
- ;
- ;Based on code modified from several sources:
- ;
- ; ALIAS.ASM Susan Glinert-Cole, version of 9.15.84
- ; Creative Computing, January 1985, pp. 173-175
- ; RENDIR.COM Mike Flynn
- ; Public domain program, version ? disassembly
- ; MOVE.COM From Windmill BBS (Terry Duke)
- ; Public domain program, disassembly
- ;
- ;Usage:
- ;
- ; A>RDIR [drive]oldname newname
- ;
- ;
- ;Function:
- ;
- ; Rename a directory or a subdirectory.
- ;
- ;Features:
- ;
- ; On-line syntax help (when null command line tail).
- ; Multi-drive OK, but no paths (current directories only).
- ; Wildcard renaming OK.
- ; Command line input check, error messages.
- ; Error messages suppressed when syntax help is given.
- ; Checks for DOS 2.0 or higher.
- ;
- ;Rationale:
- ;
- ; DOS function REN operates on files only.
- ; Glinert-Cole version has no on-line syntax help. Some typos in
- ; the published version. Extra code stripped. Apparently unaware
- ; that her version supports drives other than the default drive.
- ; Flynn version requires prompted keyboard input (no command-line input),
- ; and does not support drive specification (default drive only).
- ;
- ;
- ;Copyright 1984, Zider Brothers
- ;Released to the public domain for personal use only. All rights reserved.
- ;
- ;
- RET_NEAR MACRO
- DB 0C3H
- ENDM
-
- PRINT MACRO TEXT
- MOV DX,OFFSET TEXT ;;shorter code than LEA
- MOV AH,09
- INT 21H
- ENDM
- ;
- CSEG SEGMENT PARA PUBLIC 'CODE'
- ;
- ORG 100H
- ASSUME CS:CSEG, SS:CSEG
- ASSUME DS:CSEG, ES:CSEG
- ;
- START:
- CK_DOS: MOV AH,30H
- INT 21H
- CMP AL,2
- JNB OK_DOS
- MOV DX,OFFSET WRONG_DOS_MSG
- MOV AH,9
- INT 21H
- INT 20H
- WRONG_DOS_MSG DB 'Incorrect DOS version.',CR,LF,'$'
- OK_DOS:
- JMP BEGIN
- ;
- CR EQU 0DH
- LF EQU 0AH
- TRUE EQU 0FFH
- FALSE EQU NOT TRUE
- FCB EQU 5CH
- EFCB EQU FCB-7
- ATTR EQU FCB-1
- OK_MSG DB 'Renamed',CR,LF,'$'
- ER_MSG DB 'Directory not found.',CR,LF,'$'
- H_FLAG DB 00
- ;
- BEGIN:
- CALL INCHECK
- CMP H_FLAG,TRUE
- JZ EXIT
- MOV BX,EFCB ;load Extended File Control Block..
- MOV BYTE PTR[BX], 0FFH ;..with FF at FCB-7..
- MOV BX,ATTR ;..and 10 for the directory attribute..
- MOV BYTE PTR[BX], 10H ;..at FCB-1
- RENAME:
- MOV DX,EFCB ;give DOS the beginning of the EFCB..
- MOV AH,17H ;..and call to do the renaming
- INT 21H
- STATUS_OUT:
- CMP AL,0FFH
- JE ERROR
- PRINT OK_MSG
- EXIT:
- RET
- ERROR:
- PRINT ER_MSG
- RET
- ;
- INCHECK PROC NEAR
-
- MOV H_FLAG,TRUE ;set help flag on, assuming the worst
- MOV CL,DS:80H ;set pointer to read the command line..
- MOV CH,0 ;..tail
- CMP BYTE PTR DS:80H,0 ;check for zero length cmd line tail
- JZ ON_LINE_SYNTAX ;error if zero
- MOV DI,81H ;Start scanning line,..
- MOV AL,20H ;' ' ;..looking for leading blanks..
- REPZ SCASB ;..and skipping them
- JCXZ ON_LINE_SYNTAX ;but error if CX is zero on exit
- REPNZ SCASB ;continue scan, now for non-blank..
- JCXZ INVALID_OPERANDS_ERROR ;..and error if CX zero on exit
- REPZ SCASB ;scan for blanks..
- JCXZ INVALID_NEW_NAME_ERROR ;..error if exit before new name
- MOV H_FLAG,FALSE
- RET ;OK input
-
- INVALID_OPERANDS_ERROR:
- MOV DX,OFFSET INVALID_OPERANDS_MSG
- MOV AH,9
- INT 21H
- RET_NEAR
-
- ON_LINE_SYNTAX:
- MOV DX,OFFSET SYNTAX_MSG
- MOV AH,9
- INT 21H
- RET_NEAR
-
- INVALID_NEW_NAME_ERROR:
- MOV DX,OFFSET INVALID_NEW_NAME_MSG
- MOV AH,9
- INT 21H
- RET_NEAR
-
- INVALID_OPERANDS_MSG EQU $
- DB 'Invalid or missing operands',CR,LF,'$'
- INVALID_NEW_NAME_MSG EQU $
- DB 'Invalid or missing new name',CR,LF,'$'
- SYNTAX_MSG EQU $
- DB 'Syntax: A>RDIR [drive]oldname newname',CR,LF
- DB CR,LF
- DB ' No path allowed. Drive, wildcards OK.',CR,LF
- CRLF DB CR,LF,'$'
-
- ;
- INCHECK ENDP
- ;
- CSEG ENDS
- END START